﻿CREATE PROCEDURE [dbo].[spCreateSequenceOrder]
	@OrderID int, 
	@SequenceID int
AS
begin
	declare @SequenceOrderID int

	insert into tblSequenceOrder ( OrderID, SequenceID, OwnerID, SequenceStatusCode, CanceledReasonID )
	select @OrderID, @SequenceID, OwnerID, 'I', null 
	from tblSequence
	where SequenceID = @SequenceID
	
	set @SequenceOrderID = SCOPE_IDENTITY()

	exec spCreateSequenceStepsForOrder @SequenceID, @SequenceOrderID, null, null

	RETURN @SequenceOrderID
end